package com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.bo;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.tjsinfo.tjsoa.Dao.IQbcDao;
import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.dao.ITXingzhengshouwendengjibuDAO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.vo.TXingzhengshouwendengjibu;

public class TXingzhengshouwendengjibuBO implements ITXingzhengshouwendengjibuBO{
	private ITXingzhengshouwendengjibuDAO xingzhengshouwendengjibuDAO;
	private IQbcDao qbcDao;
	
	public IQbcDao getQbcDao() {
		return qbcDao;
	}

	public void setQbcDao(IQbcDao qbcDao) {
		this.qbcDao = qbcDao;
	}


	public ITXingzhengshouwendengjibuDAO getXingzhengshouwendengjibuDAO() {
		return xingzhengshouwendengjibuDAO;
	}

	public void setXingzhengshouwendengjibuDAO(
			ITXingzhengshouwendengjibuDAO xingzhengshouwendengjibuDAO) {
		this.xingzhengshouwendengjibuDAO = xingzhengshouwendengjibuDAO;
	}

	public Boolean addTxingzhengshouwendangjibu(TXingzhengshouwendengjibu xingzhengshouwendengjibu) {
		// TODO Auto-generated method stub
		try {
			xingzhengshouwendengjibuDAO.save(xingzhengshouwendengjibu);
			return true;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}

	public List<TXingzhengshouwendengjibu> selectAll() {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TXingzhengshouwendengjibu.class);
		return qbcDao.getCriteria(criteria);
	
	}

	public TXingzhengshouwendengjibu selectByDocId(String docid) {
		// TODO Auto-generated method stub
		DetachedCriteria criteria = DetachedCriteria.forClass(TXingzhengshouwendengjibu.class);
		criteria.add(Restrictions.eq("docid", docid));
		List<TXingzhengshouwendengjibu> list = qbcDao.getCriteria(criteria);
		if (list.size() > 0) {
			TXingzhengshouwendengjibu xingzhengshouwendengjibu = list.get(0);
			return xingzhengshouwendengjibu;
		}
		return null;
	}
	
	public Boolean updateTxingzhengdengjibu(TXingzhengshouwendengjibu xingzhengshouwendengjibu){
		try {
			xingzhengshouwendengjibuDAO.merge(xingzhengshouwendengjibu);
			return true;
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
	
}
